<<!DOCTYPE html>
<html>
<head>
	<title>函数指针</title>
	<script type="text/javascript" src='../EventUtil.js'></script>
</head>
<body>
<input type="button" value="clickMe">
<ul id="myLinks">
<li id="goSomewhere">Go somewhere</li>
<li id="doSomething">Do something</li>
<li id="sayHi">Say hi</li>
</ul>
<script type="text/javascript">
 var mbts = document.getElementsByTagName('input');
 var mb=mbts[0];

 // mb.onclick=function(event){
 // 	var type =EventUtil.getTarge(event).type;
 // 	alert(type);
 // }

var handl = function(){

	// console.log(event.currentTarget === document.body);
	// console.log(this === document.body);
	// console.log(event.targt === mb);
	// console.log();
	//this指向元素所在作用域对象
	//IE中事件处理程序都是在全局中执行，this指向window
 };





EventUtil.addHandler(mb,'click',function(event){
	console.log('case');
});

var list = document.getElementById("myLinks");

EventUtil.addHandler(list,'click',function(event){
	var target=EventUtil.getTarge(event);
	switch(target.id){
		case 'doSomething':
			 console.log('doSomething');
			break;
		case "goSomewhere":
			location.href = "http://www.wrox.com";
			break;
		case "sayHi":
			alert("hi");
			break;
	}
});

EventUtil.addHandler(document.body,'click',function(event){
	console.log('catch the event');
});

// EventUtil.addHandler(list, "click", function(event){

// 	event = EventUtil.getEvent(event);
// 	var target = EventUtil.getTarge(event);
// 	switch(target.id){
// 	case "doSomething":
// 	document.title = "I changed the document's title";
// 	break;
// 	case "goSomewhere":
// 	location.href = "http://www.wrox.com";
// 	break;
// 	case "sayHi":
// 	alert("hi");
// 	break;
// 	}
// });



</script>

</body>
</html>